package com.ywh.composetest

import android.os.Looper
import android.widget.Toast
import androidx.compose.ui.platform.LocalContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

fun Any?.toastShort(message: String?) {
    message ?: return
    val app = MyApp.instance
    if (Looper.myLooper() == Looper.getMainLooper()) {
        Toast.makeText(app, message, Toast.LENGTH_SHORT).show()
    } else {
        app.globalScope.launch(Dispatchers.Main) {
            Toast.makeText(app, message, Toast.LENGTH_SHORT).show()
        }
    }
}